package com.mes.basicdata.domain;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import org.hibernate.annotations.BatchSize;
import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;
import org.hibernate.annotations.ForeignKey;
import org.hibernate.annotations.GenericGenerator;
import org.springframework.context.annotation.Lazy;

import com.mes.common.domain.BasicModel;

@Entity()
@org.hibernate.annotations.Entity(dynamicInsert=true,dynamicUpdate=true)
@Table(name = "B_OPTIONAL_RES")
@BatchSize(size=30)
@Lazy(value=true)
@Cache(usage=CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
public class OperationDevice extends BasicModel {

	@Id
	@GenericGenerator(name = "uniqueId", strategy = "assigned")
	@Column(name="UNIQUEID",unique=true)
	private String uniqueId;
	
	@Column(name="OPUID")
	private String operationUid;
	//many-to-one
	@ForeignKey(name="null")
	@ManyToOne(fetch=FetchType.LAZY)
	@JoinColumn(name="OPUID",insertable=false,updatable=false)
	private Operation operation;
	
	@Column(name="RESUID")
	private String deviceUid;
	//many-to-one
	@ForeignKey(name="null")
	@ManyToOne(fetch=FetchType.LAZY)
	@JoinColumn(name="RESUID",insertable=false,updatable=false)
	private Device device;
	
	@Column(name="PRIORITY")
	private Integer priority;
	
	@Column(name="LOCKTYPE")
	private String constraintType;
	
	// 准备时间
	@Column(name="PREOP_TIME")
	private Float preopTime;
	
	// 单件运行时间
	@Column(name="UNIT_RUNTIME")
	private Float runTime;
	
	//卸载时间
	@Column(name="POSTOP_TIME")
	private Float postopTime;
	
	// 估计装备时间
	@Column(name="ESTIPRETIME")
	private Float estiPreopTime;
	
	// 估计运行时间
	@Column(name="ESTIRUNTIME")
	private Float estiRunTime;
	
	//只针对某一调度任务的约束
	@Column(name="APPLY_TASKUID")
	private String applyTaskUid;

	@Override
	public String getUuid() {
		// TODO Auto-generated method stub
		return this.getUniqueId();
	}
	@Override
	public void setUuid(String uuid) {
		// TODO Auto-generated method stub
		this.setUniqueId(uuid);
	}
	
	public String getUniqueId() {
		return uniqueId;
	}

	public void setUniqueId(String uniqueId) {
		this.uniqueId = uniqueId;
	}

	public String getOperationUid() {
		return operationUid;
	}

	public void setOperationUid(String operationUid) {
		this.operationUid = operationUid;
	}

	public Operation getOperation() {
		return operation;
	}

	public void setOperation(Operation operation) {
		this.operation = operation;
	}

	public String getDeviceUid() {
		return deviceUid;
	}

	public void setDeviceUid(String deviceUid) {
		this.deviceUid = deviceUid;
	}

	public Device getDevice() {
		return device;
	}

	public void setDevice(Device device) {
		this.device = device;
	}

	public Integer getPriority() {
		return priority;
	}

	public void setPriority(Integer priority) {
		this.priority = priority;
	}

	public String getConstraintType() {
		return constraintType;
	}

	public void setConstraintType(String constraintType) {
		this.constraintType = constraintType;
	}

	public Float getPreopTime() {
		return preopTime;
	}

	public void setPreopTime(Float preopTime) {
		this.preopTime = preopTime;
	}

	public Float getRunTime() {
		return runTime;
	}

	public void setRunTime(Float runTime) {
		this.runTime = runTime;
	}

	public Float getPostopTime() {
		return postopTime;
	}

	public void setPostopTime(Float postopTime) {
		this.postopTime = postopTime;
	}

	public Float getEstiPreopTime() {
		return estiPreopTime;
	}

	public void setEstiPreopTime(Float estiPreopTime) {
		this.estiPreopTime = estiPreopTime;
	}

	public Float getEstiRunTime() {
		return estiRunTime;
	}

	public void setEstiRunTime(Float estiRunTime) {
		this.estiRunTime = estiRunTime;
	}

	public String getApplyTaskUid() {
		return applyTaskUid;
	}

	public void setApplyTaskUid(String applyTaskUid) {
		this.applyTaskUid = applyTaskUid;
	}
	
	
	


}